//
//  ParkingCell.m
//  CarLife
//
//  Created by yu on 2017/11/7.
//  Copyright © 2017年 jpas. All rights reserved.
//

#import "ParkingCell.h"

@implementation ParkingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setAnnotation:(ParkingAnnotation *)annotation
{
    _annotation = annotation;
    self.titleLabel.text = annotation.title;
    
    NSString *subTitle = NSStringFormat(@"%ldm %@ %@",annotation.distance,annotation.parkingType,annotation.address);
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:subTitle];
    [attr addAttributes:@{NSFontAttributeName:SYSTEM_FONT(13),NSForegroundColorAttributeName:[UIColor baseCLBlueColor]} range:[subTitle rangeOfString:annotation.parkingType]];
    self.subTitleLabel.attributedText = attr;
}

- (IBAction)directNaviAction:(UIButton *)btn {
    
//    PPLog(@"direct navi title = %@",_annotation.title);
    NSDictionary *userInfo = @{@"latitude":@(_annotation.coordinate.latitude),@"longitude":@(_annotation.coordinate.longitude)};
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"kDirectNaviButtonAction" object:nil userInfo:userInfo];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
